#include <stdio.h>

/**
*
*
*   Author: Qu huanwen
*/
class LeaguePicks {
public:
    int* returnPicks(int position, int friends, int picks, int& len) {

        int n1 = (position - 1) * 2 + 1;
        int n2 = (friends - position) * 2 + 1;
        int ns = n1 + n2;
        int p = picks - position + 1;
        len = p % ns == 0 ? p / ns * 2 : p / ns * 2 + 1;
        int* a = new int[len];

        int n = position;
        int i = 0;
        while (n <= picks) {
            a[i] = n;
            if (i % 2 == 1)
                n += n1;
            else
                n += n2;
            i++;
        }
        return a;
    }
};

void printArray(int a[], int l) {
    for (int i = 0; i < l; i++)
        printf("%d ", a[i]);
    printf("\n");
}

int main() {
    LeaguePicks pick;
    int len;
    int* a = pick.returnPicks(3, 6, 98, len);
    printArray(a, len);
    delete a;
    return 0;
}
